{% extends "base.html" %}

{% block content %}
<div class="container mt-5">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h4 class="mb-0">编辑论文信息</h4>
                </div>
                <div class="card-body">
                    <form method="POST" enctype="multipart/form-data">
                        {{ form.hidden_tag() }}
                        <div class="mb-3">
                            {{ form.title.label(class="form-label") }}
                            {{ form.title(class="form-control") }}
                            {% for error in form.title.errors %}
                            <span class="text-danger">{{ error }}</span>
                            {% endfor %}
                        </div>
                        <div class="mb-3">
                            {{ form.description.label(class="form-label") }}
                            {{ form.description(class="form-control", rows="4") }}
                            {% for error in form.description.errors %}
                            <span class="text-danger">{{ error }}</span>
                            {% endfor %}
                        </div>
                        <div class="mb-3">
                            {{ form.programming_language.label(class="form-label") }}
                            {{ form.programming_language(class="form-control") }}
                            {% for error in form.programming_language.errors %}
                            <span class="text-danger">{{ error }}</span>
                            {% endfor %}
                        </div>
                        <div class="mb-3">
                            {{ form.price.label(class="form-label") }}
                            <div class="input-group">
                                {{ form.price(class="form-control", type="number", min="500", max="2050", step="100") }}
                                <span class="input-group-text">元</span>
                            </div>
                            {% for error in form.price.errors %}
                            <span class="text-danger">{{ error }}</span>
                            {% endfor %}
                        </div>
                        <div class="mb-3">
                            {{ form.contact_info.label(class="form-label") }}
                            {{ form.contact_info(class="form-control") }}
                            {% for error in form.contact_info.errors %}
                            <span class="text-danger">{{ error }}</span>
                            {% endfor %}
                        </div>
                        <div class="mb-3">
                            {{ form.deadline.label(class="form-label") }}
                            {{ form.deadline(class="form-control", type="date") }}
                            {% for error in form.deadline.errors %}
                            <span class="text-danger">{{ error }}</span>
                            {% endfor %}
                        </div>
                        <div class="mb-3">
                            {{ form.status.label(class="form-label") }}
                            {{ form.status(class="form-select") }}
                            {% for error in form.status.errors %}
                            <span class="text-danger">{{ error }}</span>
                            {% endfor %}
                        </div>
                        <div class="mb-3 form-check">
                            {{ form.need_environment(class="form-check-input") }}
                            {{ form.need_environment.label(class="form-check-label") }}
                        </div>
                        <div class="mb-3">
                            {{ form.proposal_file.label(class="form-label") }}
                            {{ form.proposal_file(class="form-control") }}
                            {% if thesis.proposal_file %}
                            <small class="form-text text-muted">
                                当前文件：{{ thesis.proposal_file }}
                                <a href="{{ url_for('main.download_proposal', filename=thesis.proposal_file) }}" class="btn btn-sm btn-link">
                                    <i class="fas fa-download"></i> 下载
                                </a>
                            </small>
                            {% endif %}
                            {% for error in form.proposal_file.errors %}
                            <span class="text-danger">{{ error }}</span>
                            {% endfor %}
                        </div>
                        <div class="d-flex justify-content-between">
                            <a href="{{ url_for('admin.theses') }}" class="btn btn-secondary">返回</a>
                            {{ form.submit(class="btn btn-primary") }}
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 